﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iLangl.LanguageWire.Actions;
using iLangl.Model;
using iLangl.Transport.Communication;

namespace iLangl.LanguageWire.Actions
{
	public class SyncedDataAction : BaseLWPushAction
	{
		private ActionResult _actionResult = null;
		public ActionResult ActionResult
		{
			get
			{
				return _actionResult;
			}
		}

		SyncedOneWayData _request = null;
		public SyncedDataAction(SyncedOneWayData request)
			: base()
		{
			RequestContext = new SyncedDataRequestContext();
			_request = request;
			RequestContext.SetContext(_request);
			ActionResultResponseContext responsecontext = new ActionResultResponseContext();
			ResponseContext = responsecontext;
			responsecontext.ContextUpdated += new EventHandler(responsecontext_ContextUpdated);
		}

		void responsecontext_ContextUpdated(object sender, EventArgs e)
		{
			object result = ResponseContext.GetContext();

			if (result is ActionResult)
			{
				_actionResult = result as ActionResult;
			}

			weGetResult();	
		}

		public override int TimeOutInMinutes
		{
			get
			{
				return 120;
			}
		}

		protected override string GetName()
		{
			return "SyncedDataAction";
		}

		protected override string GetVersion()
		{
			return "1";
		}
	}
}
